package com.rom.ratethehell.protocol;

import com.rom.ratethehell.Global;
import com.rom.ratethehell.R;
import com.rom.ratethehell.R.drawable;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {
    private Context mContext;
	private Profile profile;

    public ImageAdapter(Context c,Profile p) {
    	profile = p;
        mContext = c;
    }

    public int getCount() {
        return profile.getThumbs().size();
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return profile.getThumbs().get(position).getId();
    }

    // create a new ImageView for each item referenced by the Adapter
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
            imageView = new ImageView(mContext);
            imageView.setLayoutParams(new GridView.LayoutParams(200, 200));
            imageView.setScaleType(ImageView.ScaleType.FIT_XY);
            imageView.setAdjustViewBounds(true);
            imageView.setPadding(2, 2, 2, 2);
        } else {
            imageView = (ImageView) convertView;
        }
        
          imageView.setImageBitmap(profile.getThumbs().get(position).getBitmap());
//        imageView.setImageResource(mThumbIds[position]);
        return imageView;
    }


}
